home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1987 June
/
Ahoy_Magazine_87-06_1987_Double_L.d64
/
Power Squares
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
3KB
|
129 lines
10 poke53280,0:poke53281,0:poke828,1
20 print"[147]"tab(13)"power squares"
30 printtab(93)"by john fedor"
40 gosub680:gosub960:print" how many players (d, 1 or 2) ? ";
50 poke198,0
60 geta$:if(a$<"1"ora$>"2")anda$<>"d"then60
70 printa$
80 pl=val(a$)
90 dim a(5,5):rem the grid
100 z=1:pokev,100:pokev+1,76
110 fory=1to5:forx=1to5
120 ifx=3andy=3then140
130 a(x,y)=z+1
140 z=1-z:nextx,y
150 print"[147]":tu=1
151 print""tab(32)"[159][172][162][162][162][162][162][187]"
152 printtab(32)"[161] [146][159][161]"
153 printtab(32)"[161] [146][159][161]"
154 printtab(32)"[161] [146][159][161]"
155 printtab(32)"[161] [146][159][161]"
156 printtab(32)"[161] [146][159][161]"
157 printtab(32)"[188][162][162][162][162][162][146][190]"
158 print""
160 printtab(11)"[159] [146]"
170 fory=1to15
180 printtab(11)" "
190 nexty
200 printtab(11)"[159] [146]"
210 c$(1)="":c$(2)="":c$(0)="[144]":wi=0
220 print""tab(12);:fory=1to5:forx=1to5
230 printc$(a(x,y))" [157][157][157] [157][157][157] [145][145]";
240 nextx:print""chr$(13)tab(12):nexty
245 ifwi<>0then800
250 t$(1)="blue":t$(2)="red"
260 print""t$(tu)"'s turn ":pokev+21,1
270 iftu=2andpl=1orpl=0then750
280 if(peek(56322-tu)and16)<>16then280
290 x=(peek(v)-100)/24+1
300 y=(peek(v+1)-76)/24+1
310 j=(peek(56322-tu)and15)
320 if(jand1)=1theny=y+1
330 if(jand2)=2theny=y-1
340 if(jand4)=4thenx=x+1
350 if(jand8)=8thenx=x-1
360 ifx=0thenx=1
370 ifx=6thenx=5
380 ify=0theny=1
390 ify=6theny=5
400 pokev,100+(x-1)*24:pokev+1,76+(y-1)*24
410 if(peek(56322-tu)and16)=16then290
420 ifa(x,y)<>tuthen290
422 rem compare to see if on same x / y
430 fori=-5to5:ifx+i<1orx+i>5then443
432 ifa(x+i,y)<>0 then 443
435 k=sgn(i):for i1= i to 0 step-k
437 if x+i1-k<1 or x+i1-k>5then440
438 a(x+i1,y)=a(x+i1-k,y)
440 nexti1:goto480
443 nexti
445 fori=-5to5:ify+i<1ory+i>5then455
446 ifa(x,y+i)<>0 then 455
447 k=sgn(i):for i1=i to 0 step-k
448 if y+i1-k<1 or y+i1-k>5then451
450 a(x,y+i1)=a(x,y+i1-k)
451 nexti1:goto480
455 nexti
470 goto270
480 a(x,y)=0
490 tu=tu+1:iftu=3thentu=1
500 fory1=-5to5:forx1=-5to5
510 ifx1<>0 and y1<>0then550
520 ify+y1<1ory+y1>5orx+x1<1orx+x1>5then550
530 ifa(x+x1,y+y1)<>tuthen550
540 fory1=1to1:forx1=1to1:nextx1,y1:goto560
550 nextx1,y1:goto490
560 fory=1to2:forx=1to5:ifa(x,y)=1thennextx,y:ifa(1,3)=1anda(2,3)=1thenwi=1
570 fory=4to5:forx=1to5:ifa(x,y)=2thennextx,y:ifa(4,3)=2anda(5,3)=2thenwi=2
580 goto220
600 data0,0,0,0,0,0,0,0
610 data0,0,0,0,0,0,0,0
620 data0,0,0,0,0,0,127,252
630 data0,127,252,0,96,12,0,96
640 data12,0,96,12,0,96,12,0
650 data96,12,0,96,12,0,96,12
660 data0,96,12,0,127,252,0,127
670 data252,0,0,0,0,0,0,0
680 fori=0to63:reada:poke832+i,a:nexti
685 fori=49152to49206:reada:pokei,a:next:sys49152
690 v=53248
700 pokev+21,0:pokev+23,1:pokev+29,1
710 pokev+28,0:pokev+39,1
720 poke2040,13
730 pokev,148:pokev+1,124
740 return
750 rem computer's turn
755 y1=int(rnd(1)*5)+1
760 x1=int(rnd(1)*5)+1
764 ift4(tu)=x1+(y1)*6then755
766 t4(tu)=x+(y)*6
767 pokev,76+(x1)*24:pokev+1,52+(y1)*24
770 ifa(x1,y1)<>tuthen755
780 x=x1:y=y1:goto420
800 rem end of game
810 pokev+21,0
820 forx=0to255:poke53281,x:poke53280,255-x:nextx
830 poke53280,0:poke53281,0
840 x1=2:ifwi=1thenx1=6
850 poke53280,x1
860 print"[147]"t$(wi)" won!!!"
870 printtab(6)"press <return> to play again"
875 printtab(7)"or press either firebutton"
880 poke198,0
890 geta$:ifa$<>chr$(13)and(peek(56321)and16)=16and(peek(56320)and16)=16then890
895 poke198,0:run
900 data120,169,13,141,20,3,169,192
910 data141,21,3,88,96,172,60,3,136
920 data140,60,3,208,24,160,5,140,60
930 data3,174,61,3,189,49,192,141,39
940 data208,232,224,6,208,2,162,0,142
950 data61,3,76,49,234,1,3,14,6,14,3
960 print""tab(17)" "
962 forx=1to3
965 printtab(17)" "
970 nextx
975 printtab(17)" [146]"
980 print""
990 pokev,149:pokev+1,164:pokev+21,1
995 return